package com.aliothservice.catfish.identity.data;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.springframework.data.annotation.Id;

public class User {
	
	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();
		
		map.put("id", this.getId());
		map.put("phoneNumber", this.getPhoneNumber());
		if (null != this.getIndividualInfo()) {
			map.put("individualInfo", this.getIndividualInfo().toMap());
		}
		if (null != this.getEnterpriseInfo()) {
			map.put("enterpriseInfo", this.getEnterpriseInfo().toMap());
		}
		if (null != this.getRejectedIndividualInfo()) {
			map.put("rejectedIndividualInfo", this.getRejectedIndividualInfo().toMap());
		}
		if (null != this.getRejectedEnterpriseInfo()) {
			map.put("rejectedEnterpriseInfo", this.getRejectedEnterpriseInfo().toMap());
		}
		DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
		map.put("registrationDate", formatter.format(this.getRegistrationDate()));
		if (null != this.avatarId) {
			map.put("avatarId", this.getAvatarId());
		}
		
		return map;
	}
	
	@Id
	private String id;
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	private String phoneNumber;
	private String password;
	
	private IndividualPending individualInfo;
	private EnterprisePending enterpriseInfo;
	
	private IndividualPending rejectedIndividualInfo;
	private EnterprisePending rejectedEnterpriseInfo;
	
	// status of the account determines the level of authorized operations
	private String accountStatus;
	
	private Date registrationDate;
	
	private Float balance;
	private Float withdrawBalance;
	private String withdrawStatus;
	
	private String avatarId;
	
	private Map<String, String> data;
	
	// last signed in mobile device, e.g. iOS, Android
	private String mobileDeviceOS;
	
	// umeng notification
	private String deviceToken;

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public Date getRegistrationDate() {
		return registrationDate;
	}

	public void setRegistrationDate(Date registrationDate) {
		this.registrationDate = registrationDate;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getAccountStatus() {
		return accountStatus;
	}

	public void setAccountStatus(String accountStatus) {
		this.accountStatus = accountStatus;
	}
	
	public IndividualPending getIndividualInfo() {
		return individualInfo;
	}

	public void setIndividualInfo(IndividualPending individualInfo) {
		this.individualInfo = individualInfo;
	}

	public EnterprisePending getEnterpriseInfo() {
		return enterpriseInfo;
	}

	public void setEnterpriseInfo(EnterprisePending enterpriseInfo) {
		this.enterpriseInfo = enterpriseInfo;
	}

	public String getMobileDeviceOS() {
		return mobileDeviceOS;
	}

	public void setMobileDeviceOS(String mobileDeviceOS) {
		this.mobileDeviceOS = mobileDeviceOS;
	}

	public Float getBalance() {
		return balance;
	}

	public void setBalance(Float balance) {
		this.balance = balance;
	}

	public Float getWithdrawBalance() {
		return withdrawBalance;
	}

	public void setWithdrawBalance(Float withdrawBalance) {
		this.withdrawBalance = withdrawBalance;
	}

	public IndividualPending getRejectedIndividualInfo() {
		return rejectedIndividualInfo;
	}

	public void setRejectedIndividualInfo(IndividualPending rejectedIndividualInfo) {
		this.rejectedIndividualInfo = rejectedIndividualInfo;
	}

	public EnterprisePending getRejectedEnterpriseInfo() {
		return rejectedEnterpriseInfo;
	}

	public void setRejectedEnterpriseInfo(EnterprisePending rejectedEnterpriseInfo) {
		this.rejectedEnterpriseInfo = rejectedEnterpriseInfo;
	}

	public String getAvatarId() {
		return avatarId;
	}

	public void setAvatarId(String avatarId) {
		this.avatarId = avatarId;
	}

	public Map<String, String> getData() {
		return data;
	}

	public void setData(Map<String, String> data) {
		this.data = data;
	}

	public String getWithdrawStatus() {
		return withdrawStatus;
	}

	public void setWithdrawStatus(String withdrawStatus) {
		this.withdrawStatus = withdrawStatus;
	}

	public String getDeviceToken() {
		return deviceToken;
	}

	public void setDeviceToken(String deviceToken) {
		this.deviceToken = deviceToken;
	}

	public static final String ACCOUNT_STATUS_CREATED = "created";
	public static final String ACCOUNT_STATUS_VERIFIED = "certificated";
	public static final String ACCOUNT_STATUS_FROZEN = "frozen";
	
	public static final String WITHDRAW_STATUS_IN_PROGRESS = "in_progress";
	public static final String WITHDRAW_STATUS_OPEN_FOR_WITHDRAW = "open_for_withdraw";

}
